
/* --------------------------------------- Include Files ---------------------------------------- */
#include "stm32f10x.h"
#include "system_timer.h"
#include "driver.h"
#include "parameter.h"
#include "core.h"


/* ---------------------------------------- Macro Defines --------------------------------------- */


/* -------------------------------------- Data Type Defines -------------------------------------- */


/* --------------------------------- Global Function Prototypes --------------------------------- */
uint32_t Core_initDBS(uint32_t format);
uint32_t Core_createVersionPayload(uint8_t* buf, uint32_t* length);
uint32_t Core_createStatusPayload(uint32_t group, uint8_t* buf, uint32_t* length);
uint32_t Core_createRdParamentResponesPayload(uint16_t par_id, uint16_t par_number,uint8_t* buf, uint32_t* length);
uint32_t Core_createWrParamentResponesPayload(uint16_t par_id, uint16_t par_number, uint8_t* par_content, uint8_t* buf, uint32_t* length);

/* --------------------------------- Private Function Prototypes -------------------------------- */


/* -------------------------------------- Static Variables -------------------------------------- */


/*************************************************************************************************
 * Procedure: Core_initDBS
 * Object: 
 * Parameters In:
 * - none
 * Parameters Out:
 * - none
 *************************************************************************************************/
uint32_t Core_initDBS(uint32_t format)
{
	uint32_t result = 0;
	
    if(format == 1){      
        Dbs_setParDefault();
        printf("Database memory load defaults.\r\n");
	}
	
	result = Dbs_initParTable();       
	if(result==0){ 
		printf("Database memory has errors,try to restore to default.\r\n");
		Dbs_setParDefault();		
		printf("Database memory has errors,try to restore to default.\r\n");
		watchdog_reset();
	 }else{
	     return 1;
	 }
}

